home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Newton Sample Code 1.2 / Views / DatePick-2 / DatePick.text < prev    next >
Encoding:
Text File  |  1994-02-28  |  5.8 KB  |  215 lines  |  [TEXT/MPS ]

  1.  
  2. // ---- End Project Data ----
  3.  
  4.  
  5. // ---- File DatePick.t ----
  6.  
  7. // Before Script for "monthPickerExample"
  8. //Copyright 1993-1994 Apple Computer, Inc.
  9.  
  10. monthPickerExample :=
  11.    {title: "clMonthView Sample",
  12.     viewBounds: {top: 0, left: 0, right: 240, bottom: 335},
  13.     viewFlags: 516,
  14.     selectedDates: [],
  15.     viewSetupFormScript:
  16.       func()
  17.       begin
  18.       local b := GetAppParams();
  19.       constant kMaxWidth := 240;
  20.       constant kMaxHeight := 336;
  21.       
  22.       viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
  23.               Min(b.appAreaWidth, kMaxWidth),
  24.               Min(b.appAreaHeight, kMaxHeight) );
  25.       
  26.       
  27.           selectedDates := [Time()];
  28.       
  29.       end,
  30.     _proto: protoApp,
  31.     debug: "monthPickerExample"
  32.    };
  33.  
  34.  
  35. // ---- File protoDatePicker ----
  36.  
  37. // Before Script for "protoDatePicker"
  38. // Copyright 1993-1994 Apple Computer, Inc.
  39.  
  40. protoDatePicker :=
  41.    {viewFlags: 1,
  42.     viewFormat: nil,
  43.     viewBounds: {left: 0, top: 0, right: 120, bottom: 100},
  44.     monthChangedScript:
  45.       func()
  46.       begin
  47.           // This will be inherited by the child month view and called every time
  48.           // the user taps on a new day.  It *must* be here because the user can
  49.           // tap on days at the end or beginning of the previous or next month
  50.           // (the blank spaces on the view) and actually change the date!
  51.           // If this script isn't here to update the view and the title string,
  52.           // the month with change but the display won't--confusing the heck out of
  53.           // people.
  54.           :Dirty();
  55.           :SetTitle();
  56.       end,
  57.     monthYearSpec:
  58.       GetDateStringSpec([
  59.               [kElementMonth, kFormatLong],
  60.               [kElementYear,  kFormatLong]]),
  61.     SetTitle:
  62.       // This function updates the month/year label.  It should be called
  63.       // whenever the user changes the date.
  64.       
  65.       func()
  66.       begin
  67.           SetValue(monthYearLabel, 'text,
  68.                    LongDateStr(selectedDates[0], monthYearSpec));
  69.       end,
  70.     viewSetupDoneScript:
  71.       func()
  72.       begin
  73.           if NOT selectedDates exists then
  74.               self.selectedDates := [Time()];  // initialize selectedDates to current
  75.           :SetTitle();
  76.       end,
  77.     Refresh:
  78.       // This allows scripts outside the proto to have a nice entry point for
  79.       // getting the picker refreshed when the selectedDates array changes.
  80.       
  81.       func()
  82.       begin
  83.           monthView:Dirty();
  84.           :SetTitle();
  85.       end,
  86.     viewclass: 74,
  87.     debug: "protoDatePicker"
  88.    };
  89.  
  90. monthYearLabel := /* child of protoDatePicker */
  91.    {text: "",
  92.     viewBounds: {left: 0, top: 0, right: 0, bottom: 15},
  93.     viewFlags: 3,
  94.     viewJustify: 8388662,
  95.     _proto: protoStaticText,
  96.     debug: "monthYearLabel"
  97.    };
  98. // View monthYearLabel is declared to protoDatePicker
  99.  
  100.  
  101.  
  102. previousMonthButton := /* child of protoDatePicker */
  103.    {viewBounds: {left: 0, top: 0, right: 15, bottom: 15},
  104.     viewSetupFormScript:
  105.       func()
  106.       begin
  107.           // initialize the icon from the system bitmap via a magic pointer.
  108.           self.icon := @325;    // leftBitmap
  109.       end,
  110.     viewFlags: 515,
  111.     viewJustify: 6,
  112.     viewFormat: 1,
  113.     buttonPressedScript:
  114.       func()
  115.       begin
  116.           // move to the previous month, and make sure the views redraw.
  117.           selectedDates[0] := IncrementMonth(selectedDates[0], -1);
  118.           monthView:dirty();
  119.           :SetTitle();
  120.       
  121.           // have to call RefreshViews because this is the buttonPressedScript,
  122.           // the view otherwise wouldn't get refreshed until the user lifted the
  123.           // pen!  If you had done this in the buttonClickScript instead, you
  124.           // could skip the RefreshViews() call.
  125.           RefreshViews();
  126.       end,
  127.     icon: nil,
  128.     _proto: protoPictureButton,
  129.     debug: "previousMonthButton"
  130.    };
  131.  
  132.  
  133.  
  134. nextMonthButton := /* child of protoDatePicker */
  135.    {icon: nil,
  136.     viewBounds: {top: 0, left: -15, right: 0, bottom: 15},
  137.     viewSetupFormScript:
  138.       func()
  139.       begin
  140.           // initialize the bitmap from the system ROMs via a magic pointer.
  141.       
  142.       self.icon := @326;    // rightBitmap
  143.       end,
  144.     viewFlags: 515,
  145.     viewFormat: 1,
  146.     viewJustify: 38,
  147.     buttonPressedScript:
  148.       func()
  149.       begin
  150.           // move to the previous month, and make sure the views redraw.
  151.           selectedDates[0] := IncrementMonth(selectedDates[0], 1);
  152.           monthView:dirty();
  153.           :SetTitle();
  154.       
  155.           // have to call RefreshViews because this is the buttonPressedScript,
  156.           // the view otherwise wouldn't get refreshed until the user lifted the
  157.           // pen!  If you had done this in the buttonClickScript instead, you
  158.           // could skip the RefreshViews() call.
  159.           RefreshViews();
  160.       end,
  161.     Copyright: "Copyright 1993-1994 Apple Computer, Inc.",
  162.     _proto: protoPictureButton,
  163.     debug: "nextMonthButton"
  164.    };
  165.  
  166.  
  167.  
  168. monthView := /* child of protoDatePicker */
  169.    {viewBounds: {top: 15, left: 1, right: -1, bottom: -1},
  170.     viewFlags: 513,
  171.     viewFormat: nil,
  172.     labelFont: ROM_fontSystem9Bold,
  173.     dateFont: ROM_fontSystem9,
  174.     viewJustify: 246,
  175.     singleDay: true,
  176.     viewclass: 80,
  177.     debug: "monthView"
  178.    };
  179. // View monthView is declared to protoDatePicker
  180.  
  181.  
  182.  
  183.  
  184. // ---- Back in File DatePick.t ----
  185. datePicker := /* child of monthPickerExample */
  186.    {viewBounds: {left: 41, top: 25, right: 161, bottom: 113},
  187.     viewFormat: 336,
  188.     _proto: protoDatePicker,
  189.     debug: "datePicker"
  190.    };
  191. // View datePicker is declared to monthPickerExample
  192.  
  193.  
  194.  
  195. _view000 := /* child of monthPickerExample */
  196.    {text: "Today",
  197.     buttonClickScript:
  198.       func()
  199.       begin
  200.           selectedDates := [Time()]; // get current date/time
  201.           datePicker:Refresh();
  202.       end,
  203.     viewBounds: {left: 44, top: 124, right: 160, bottom: 144},
  204.     _proto: protoTextButton
  205.    };
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. // ---- Beginning of section for non used Layout files ----
  214.  
  215. // End of output